#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Shangzhetong
# Date: 2016-06-20

"""
    众盟超级卡券微服务
    实现对微信公众号(超级卡券)相关数据的操作
    以及相关服务用API实现
"""

import os
import time, json

from glogging import glogging_init, glogging_process_info;
from glapiserv import GLAPIServ;

def processor1(request):
    print request.request.body
    print request.get_argument("kk",  "aaaa")
    request.write("Pong");
    request.finish();


def processor2(request):
    print request.request.method
    request.write("response kk");
    request.finish();

demo_processes = {
    'name1':    {
            'processor':  processor1,
            'cores': 3,
            'pattern': '/api/ping/',
    },
    'name2':    {
            'processor':  processor2,
            'cores': 1,
            'pattern': '/api/kk/',
    },
}




if __name__ == '__main__':

    settings = {
        'debug': True,
        'gzip': True,
        'autoescape': None,
        'xsrf_cookies': False,
    }

    glogging_init('./', 'log');

    s = GLAPIServ('0.0.0.0', 8888, demo_processes, settings);
    s.start();

    while True:
        time.sleep(1);

    os._exit(99);

